#include "KeyRecommander/Configuration.h"
#include "KeyRecommander/DictProducer.h"
#include "KeyRecommander/Singleton.hpp"
#include "KeyRecommander/SplitTool.h"
#include <cstddef>
#include <iostream>

void TestConfiguration();
void TestSplitTool();
void TestProducer();

int main() {
    // TestConfiguration();
    // TestSplitTool();
    TestProducer();
}



void TestConfiguration() {
    using namespace NATSUME;

    InforArgs       inforArgs;  // 实例化宏结构体
    Configuration   *pConf = Singleton<Configuration>::getInstance(inforArgs.CONFIG_PATH);

    PRINT_ELEMENTS(pConf->getConfigMap());
    // PRINT_ELEMENT(pConf->getCN_StopWordList());
    // PRINT_ELEMENT(pConf->getCN_StopWordList());
    int i = 0, j = 0;
    for (const auto & elem : pConf->getEN_StopWordList()) {
        std::cout << elem << " " << std::endl;
        if (i >= 3) {
            break;
        }
        ++i;
    }
    for (const auto & elem : pConf->getCN_StopWordList()) {
        std::cout << elem << " " << std::endl;
        if (j >= 3) {
            break;
        }
        ++j;
    }
}

void TestSplitTool() {
    using namespace NATSUME;

    InforArgs       inforArgs;
    Configuration   *pConf      = Singleton<Configuration>::getInstance(inforArgs.CONFIG_PATH);
    SplitTool       *pSplitTool = SplitToolManager::create(pConf);

    std::string     sentence1   = "之所以, 不仅 夏目贵志和猫咪老师";
    std::string     sentence2   = "风柯月渚, 并可传心; 烟岛云林, 咸提妙旨";
    std::string     sentence3   = "Natsume Saying to NeiKouSanSAN . about about";
    std::vector<std::string>    result1, result2, result3;

    result1 = pSplitTool->cutCN(sentence1); 
    PRINT_ELEMENT(result1);
    result2 = pSplitTool->cutCN(sentence2);
    PRINT_ELEMENT(result2);

    STRING_TO_LOWER(sentence3);
    result3 = pSplitTool->cutEN(sentence3);
    PRINT_ELEMENT(result3);
}

void TestProducer() {
    using namespace NATSUME;

    InforArgs       inforArgs;
    Configuration   *pConf      = Singleton<Configuration>::getInstance(inforArgs.CONFIG_PATH);
    SplitTool       *pSplitTool = SplitToolManager::create(pConf);
    auto            configMap   = pConf->getConfigMap();


    EnDictProducer  pEnDict(configMap["EN_YULIAO_PATH"], pSplitTool);
    pEnDict.showEn_Files();
    pEnDict.buildEn_Dict();
    pEnDict.storeEn_Dict(configMap["EN_DICT_STORE_PATH"]);
    pEnDict.buildEn_Index();
    pEnDict.storeEn_Index(configMap["EN_INDEX_STORE_PATH"]);

    CnDictProducer  pCnDict(configMap["CN_YULIAO_PATH"], pSplitTool);
    pCnDict.showCn_Files();
    pCnDict.buildCn_Dict();
    pCnDict.storeCn_Dict(configMap["CN_DICT_STORE_PATH"]);
    pCnDict.buildCn_Index();
    pCnDict.storeCn_Index(configMap["CN_INDEX_STORE_PATH"]);

}